// /recipel/infobyid
import request from "../../utils/request.ts";
import { message } from "antd";
import type { AxiosResponse } from "axios";

//获取处方综合管理
export const getPreManagementList = async (): Promise<any> => {
  try {
    const res: AxiosResponse<any, any> = await request.get("/recipel/list", {
      page: 1,
      size: 100,
    });
    if (res.data.code === 1) {
      return res.data;
    }
    message.error(res.data.msg);
  } catch (err) {
    message.error("获取处方综合管理列表失败");
    throw err;
  }
};
//删除处方综合管理
export const delPreManagementRow = async (prams): Promise<any> => {
  try {
    const res: AxiosResponse<any, any> = await request.get("/recipel/del", {
      id: prams,
    });
    if (res.data.code === 1) {
      return res.data;
    }
    message.error(res.data.msg);
  } catch (err) {
    message.error("删除处方综合管理列表失败");
    throw err;
  }
};
//删除选中处方综合管理
export const delPreManagementList = async (prams): Promise<any> => {
  try {
    const res: AxiosResponse<any, any> = await request.post(
      "/recipel/batchdel",
      {
        ids: prams,
      }
    );
    if (res.data.code === 1) {
      return res.data;
    }
    message.error(res.data.msg);
  } catch (err) {
    message.error("删除选中处方综合管理列表失败");
    throw err;
  }
};
//查询处方
export const getPreManagementInfo = async (prams): Promise<any> => {
  try {
    const res: AxiosResponse<any, any> = await request.get(
      "/recipel/infobyid",
      {
        id: prams,
      }
    );
    if (res.data.code === 1) {
      return res.data;
    }
    message.error(res.data.msg);
  } catch (err) {
    message.error("查询处方失败");
    throw err;
  }
};
